#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Hubs,  S2, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S3, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Sensor, S4,     angle,          sensorI2CCustomFastSkipStates)
#pragma config(Motor,  motorA,          C1,            tmotorNormal, openLoop, encoder)
#pragma config(Motor,  motorB,          C2,            tmotorNormal, openLoop, encoder)
#pragma config(Motor,  motorC,          C3,            tmotorNormal, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C1_1,     FL,            tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     FR,            tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     RL,            tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S2_C1_2,     RR,            tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S3_C1_1,     Arm,           tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C1_2,     Lift,          tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    Spin,                tServoStandard)
#pragma config(Servo,  srvo_S1_C2_2,    Grippy,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_3,    GrabL,                tServoStandard)
#pragma config(Servo,  srvo_S1_C2_4,    GrabR,                tServoStandard)
#pragma config(Servo,  srvo_S1_C2_5,    Lift2,                tServoStandard)
#pragma config(Servo,  srvo_S1_C2_6,    Lift1,                tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                           Autonomous Mode Code Template
//
// This file contains a template for simplified creation of an autonomous program for an TETRIX robot
// competition.
//
// You need to customize two functions with code unique to your specific robot.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

#include "include.h"



/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                    initializeRobot
//
// Prior to the start of autonomous mode, you may want to perform some initialization on your robot.
// Things that might be performed during initialization include:
//   1. Move motors and servos to a preset position.
//   2. Some sensor types take a short while to reach stable values during which time it is best that
//      robot is not moving. For example, gyro sensor needs a few seconds to obtain the background
//      "bias" value.
//
// In many cases, you may not have to add any code to this function and it will remain "empty".
//
/////////////////////////////////////////////////////////////////////////////////////////////////////



void initializeRobot()
{
  // Place code here to sinitialize servos to starting positions.
  // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.
  while(true)
  {if(nNxtButtonPressed==kRightButton)
    {
      motor[Arm]=100;
    }
    else if (nNxtButtonPressed==kLeftButton)
    {
      motor[Arm]=-100;
    }
    else
    {
      motor[Arm]=0;
    }
    if(nNxtButtonPressed==kEnterButton)
    {
      HTANGresetAccumulatedAngle(angle);
      wait10Msec(20);
      break;
    }
  }

  MoveArm(inital);
  StartTask(PositionArm);
  servo[Spin]=128;
  servo[Grippy]=110;
  servo[GrabL]=255;
  servo[GrabR]=0;
  servo[Lift1]=230;
  servo[Lift2]=0;
  chooser();
  return;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                         Main Task
//
// The following is the main code for the autonomous robot operation. Customize as appropriate for
// your specific robot.
//
// The types of things you might do during the autonomous phase (for the 2008-9 FTC competition)
// are:
//
//   1. Have the robot follow a line on the game field until it reaches one of the puck storage
//      areas.
//   2. Load pucks into the robot from the storage bin.
//   3. Stop the robot and wait for autonomous phase to end.
//
// This simple template does nothing except play a periodic tone every few seconds.
//
// At the end of the autonomous period, the FMS will autonmatically abort (stop) execution of the program.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////


task main()
{

  initializeRobot();

  waitForStart(); // Wait for the beginning of autonomous phase.

  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  ////                                                   ////
  ////    Add your robot specific autonomous code here.  ////
  ////                                                   ////
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  wait1Msec(1000*waittime);
  straight(90,6000);
  wait10Msec(50);
  turn(90,440);
  wait10Msec(50);
  //MoveArm(-10);
  straight(90,8000);
  wait10Msec(5000);

  while(true)
  {}
}
